package com.yuand.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.yuand.entity.Menu;
import com.yuand.mapper.MenuMapper;
import com.yuand.service.SysMenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author yuandong
 * @date 2021/9/24 15:10
 */
@Service
public class SysMenuServiceImpl implements SysMenuService {

    @Autowired
    private MenuMapper sysMenuMapper;

    @Override
    public Boolean hasChildren(Integer menuId) {
        //select count(1) from sys_menu where parent_id = #{menuId}
        QueryWrapper<Menu> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("pid", menuId);

        Integer result = this.sysMenuMapper.selectCount(queryWrapper);

        return result > 0 ? true : false;
    }


}
